Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.8K
Vistas
After update typescript ^3.7.2 to latest "typescript": "^4.4.4" - error TS2339: Property 'msSaveOrOpenBlob' does not exist on type 'Navigator'

I have used this msSaveOrOpenBlob method . its was working properly but after update typescript into latest version I am getting multiple error there is two error .

window.navigator.msSaveOrOpenBlob(data, filename);

error TS2322: Type 'Promise<>' is not assignable to type 'IPromise<>'.

What is the fix of that .

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

It's my first development in angular more specific in the 12 version, and I created a method in a component that does a download a xlsx file, in Chrome its work but in IE it doesn't work, I find that adding this line window.navigator.msSaveOrOpenBlob(data, filename); Explorer can download file, but in VSC mark error and it is

Property 'msSaveOrOpenBlob' does not exist on type 'Navigator'

and I change the module and lib in tsconfig.json,

"module": "es2020",
"lib": [
    "es2020",
    "dom"
]

to:

"module": "es2015",
"lib": [
    "es2015",
    "dom"
]

In the code window.navigator.msSaveOrOpenBlob VSC mark the same

Property 'msSaveOrOpenBlob'....'

but when I execute ng serve its work and download a xlsx file in IE and Chrome.

over 4 years ago · Santiago Trujillo Denunciar

0

msSaveOrOpenBlob was a proprietary addition to the Navigator object, added by Microsoft for Internet Explorer. Since Microsoft is phasing out support for Internet Explorer, it has removed support for many of the non-standard additions made to the lib.dom.d.ts and lib.es*.d.ts files that ship with TypeScript. See this GitHub issue about the changes to the DOM.d.ts file.

As indicated in this GitHub issue on the subject, you will have to use declaration merging to add these types to Navigator yourself.

over 4 years ago · Santiago Trujillo Denunciar

0

@Heretic Monkey answer is correct, but if you just want to get around the issue - since you are using TypeScript - you can just cast it to type any before calling msSaveOrOpenBlob.

(window.navigator as any).msSaveOrOpenBlob(data, filename);

Also, you should make sure the navigator object does have the method in the first place, so:

const nav = (window.navigator as any);
if (nav.msSaveOrOpenBlob) {
  nav.msSaveOrOpenBlob(data, filename);
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda